草庐IT

MySQL CSV 导入 : datetime value

全部标签

python - 从同一目录导入 __init__.py 和模块时 python 2.7 和 3.3+ 之间的区别

最近我遇到一个问题signalIwasusingfromflask-securitywasnotbehavingasexpected在python3.3。在查看flask-security的源代码时,我注意到我从flask-security包中的模块导入的信号也被导入到__init__.py中。通过从包的顶层导入信号,我能够解决我的问题(因为信号是在包初始化时导入的)。如果我运行以下代码:fromflask.ext.securityimportuser_registeredfromflask.ext.security.signalsimportuser_registeredasuser

python - 从选定位置导入 Python 模块

假设我有三个脚本。Main.py(包含所有导入)、1.py(随机脚本)、2.py(随机脚本)。pyinstaller-F--onedirMain.py(80mb)pyinstaller-F--onedir1.py(80mb)pyinstaller-F--onedir2.py(80mb)这会创建3个文件夹,然后我将1.exe和2.exe复制到具有所有依赖项的Main文件夹,并且运行正常。存在两个问题:问题是大小。一个文件减少到30mb,一个文件夹保持在80mb更重要的是,exe无法离开该文件夹。我不得不求助于在Python中使用快捷方式。我正在关注this,这应该是一种解决方法。我的问题

python - 导入tensorflow报错: terminate called after throwing an instance of 'Xbyak::Error'

我正在尝试使用tensorflow调试错误。当我导入tensorflow时我收到以下错误importtensorflowastfterminatecalledafterthrowinganinstanceof'Xbyak::Error'what():internalerrorAborted(coredumped)这是安装细节操作系统>>Ubuntu14.04安装方法Anaconda>>conda4.4.11(condainstalltensorflow)python3--version>>Python3.6.4::Anaconda,Inc.如果有人有解决此问题的经验或知识,我将不胜感激

python - 使用 channel 2 运行服务器时无法导入 ASGI_APPLICATION 模块

我已按照channel教程进行操作,但在运行时抛出这些错误包的版本是channel==2.1.2Django==2.0.4我错过了什么?在settings.py中INSTALLED_APPS=["channels"....]ROOT_URLCONF='myapp.urls'ASGI_APPLICATION="myapp.routing.application"添加文件mayapp/routing.pyfromchannels.routingimportProtocolTypeRouterapplication=ProtocolTypeRouter({#Emptyfornow(http-

python - 导入 Cython 模块时出现 undefined symbol 错误

我想将我的一个C++类作为Python模块提供。该类在headerFoo.h中声明,并在.cppFoo.cpp中实现。(g++-4.5,Ubuntux86_64)。这是一个非常非常简单的类:Foo.cpp:Foo::Foo():alfa(1.0),beta(1){}Foo::~Foo(){}Foo.h:classFoo{public:Foo()Foo(constFoo&orig);~Foo();doublealfa;intbeta;};我创建了一个setup.py,如Cython教程所示:setup.pyfromdistutils.coreimportsetupfromdistutil

python - 获取类的 self.__module__ 而不管如何导入

我有一个库类,其中取决于它是如何导入的,一种依赖于self.__module__的方法来识别更改行为-取决于我是相对导入还是绝对导入。有没有办法强制类的self.__name__属性绝对返回自身?我意识到一个解决方案是强制每个人以相同的方式导入子类,但想知道是否有一种方法可以从库的角度强制执行它。概要结构我在库中有一个模块project/mylib/foo.pyLibraryClassdefget_name(self):return"%s.%s.%s"%\(self.__module__,self.__class__.__name__,self.some_init_property)p

python - Pandas导入CSV和Excel文件报错

我正在尝试使用PythonPandas导入CSV文件。此文件中的示例数据如下,其中第一行是用逗号分隔的列名。EndCustomerOrganizationID,EndCustomerOrganizationName,EndCustomerTopParentOrganizationID,EndCustomerTopParentOrganizationName,ResellerTopParentID,ResellerTopParentName,Business,RevSumDivision,RevSumCategory,ProductFamily,Version,PricingLevel,

python - 删除 python 循环导入

用户.py:fromstoryimportStoryclassUser:...defget_stories(self):story_ids=[selectfromdatabase]return[Story.get_by_id(id)foridinstory_ids]故事.pyfromuserimportUserclassStory:...def__init__(self,id,user_id,content):self.id=idself.user=User.get_by_id(user_id)self.content=content如您所见,此程序中存在循环导入,这会导致Import

Python 导入模块、文件夹结构

我一直在寻找解决这个问题的方法。我有一个python项目,这是我想要的文件夹结构:/project/main.py/project/src/models.py/project/test/tests.py我希望能够通过在终端中执行tests.py来运行测试。tests.py导入/project/src/中的模块进行测试。首先我通过添加解决了这个问题sys.path.insert(0,'..')在tests.py中。但是models.py中用于打开文本文件的路径必须是相对于tests.py等的路径。这意味着程序不会在执行时运行ma​​in.py,路径的原因。在将模块导入tests.py时,

python - 使用 vtk 时导入的 undefined variable

我使用与Ubuntu包管理器一起安装的python-vtk6.2.0在python2.7中编码。我使用eclipse+pydev作为IDE,我可以在shell和eclipse中成功运行代码。我遇到的唯一烦人的问题是代码分析器不断发布以下类型的错误:Undefinedvariablefromimport:vtkxxxxxx每当我这样做时importvtkvtk.vtkTransformPolyDataFiltervtk.vtkActorvtk.vtkWhatever我尝试重置解释器,我也尝试手动将库.so文件添加到PYTHONPATH,但没有成功。我还可以在系统库下的项目树中看到vtk包